package com.tzbank.wisdom.controller;

import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.tzbank.utils.CodeUtil;
import com.tzbank.utils.ResultUtil;
import com.tzbank.wisdom.service.MyCardPackageService;

import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;

@Api(tags = { "我的卡包" })
@Slf4j
@RequestMapping("myCard")
@RestController
public class MyCardPackageController {

	@Autowired
	private MyCardPackageService myCardPackageService;

	/**
	 * 我的卡包-卡列表
	 * @param reqParams
	 * @return Map<String, Object>
	 * @author XUZONGTIAN 2018年6月26日
	 */
	@PostMapping(value = "myCardList")
	public Map<String, Object> myCardList(@RequestBody Map<String, String> reqParams) {
		try {
			return this.myCardPackageService.myCardList(reqParams);
		} catch (Exception e) {
			log.error("myCardList error: ", e);
			return ResultUtil.resultMap(CodeUtil.CODE_500.getName(), CodeUtil.CODE_500.getCode(), null);
		}
	}
	
	@PostMapping(value = "queryCard")
	public Map<String, Object> queryCard(@RequestBody Map<String, String> reqParams) {
		try {
			
			return myCardPackageService.queryCard(reqParams);
		} catch (Exception e) {
			log.error("myCardList error: ", e);
			return ResultUtil.resultMap(CodeUtil.CODE_500.getName(), CodeUtil.CODE_500.getCode(), null);
		}
	}

	/**
	 * 我的卡包-添加卡片
	 * @param reqParams
	 * @return
	 * @author XUZONGTIAN 2018年6月28日
	 */
	@PostMapping(value = "add")
	public Map<String, Object> addCard(@RequestBody Map<String, Object> reqParams) {
		try {
			return myCardPackageService.addCard(reqParams);
		} catch (Exception e) {
			log.error("addCard error: ", e);
			return ResultUtil.resultMap(CodeUtil.CODE_500.getName(), CodeUtil.CODE_500.getCode(), null);
		}
	}
	
	@PostMapping(value = "goAddCard")
	public Map<String, Object> goAddCard(@RequestBody Map<String, Object> reqParams) {
		try {
			return myCardPackageService.goAddCard(reqParams);
		} catch (Exception e) {
			log.error("addCard error: ", e);
			return ResultUtil.resultMap(CodeUtil.CODE_500.getName(), CodeUtil.CODE_500.getCode(), null);
		}
	}

	/**
	 * 我的卡包-解挂
	 * @param reqParams
	 * @return
	 * @author XUZONGTIAN 2018年6月27日
	 */
	@PostMapping(value = "delete")
	public Map<String, Object> deleteCard(@RequestBody Map<String, Object> reqParams) {
		try {
			return this.myCardPackageService.deleteCard(reqParams);
		} catch (Exception e) {
			log.error("deleteCard error: ", e);
			return ResultUtil.resultMap(CodeUtil.CODE_500.getName(), CodeUtil.CODE_500.getCode(), null);
		}
	}

}
